<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head lang="en">
    <meta charset="UTF-8">
    <%@include file="style.jsp" %>
    <%@include file="script.jsp" %>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/orderlang/distributor/css/mainpage_product.css"/>
    <title>首页商品设置</title>
</head>
<body onselectstart="return false">
<div id="container_1" style="height:100%">
    <div style="position: relative">
        <%@include file="header.jsp" %>
    </div>
    <div id="content" class="clearfix">
        <%@include file="left_menu.jsp" %>
        <!--内容部分-->
        <div class="right-content" style="margin:75px 20px 0 213px;">
            <p class="brand">
                <a>商品</a>><a class="now">首页商品设置</a>
            </p>
            <div class="tab clearfix">
                <div class="chose-product active" onclick="location.reload()">首页展示商品</div>
                <div class="revise" onclick="getProduct()">添加首页商品</div>
            </div>
            <form class="show-form" action="">
                <div class="content show-block" style="height: 700px">
                    <div class="cancel-show fr">取消首页展示</div>
                    <span class="prompt fr"><i>?</i>排序值越大，商品展示越靠前</span>
                    <table>
                        <thead>
                        <tr>
                            <td><s></s></td>
                            <td>商品图片</td>
                            <td>商品名称</td>
                            <td>规格</td>
                            <td>标准</td>
                            <td>市场价</td>
                            <td>订货价</td>
                            <td>进货价</td>
                            <td>排序值</td>
                            <td></td>
                        </tr>
                        </thead>
                        <tbody>
                        	<c:forEach var="product" items="${mainpageProduct }" >
                        <tr >
                            <td><s></s></td>
                            <td>
                                <div>
                                    <img src="${pageContext.request.contextPath}/img/1.jpg"/>
                                </div>

                            </td>
                            <td>
                                <p>${product.code }</p>
                                <p>${product.productName }</p>
                                <p>${product.brandName }</p>
                            </td>
                            <td>${product.groupSpecValue }</td>
                            <td>${product.standard }</td>
                            <td>${product.price }/${product.littleUnit}</td>
                            <td>${product.orderedPrice }/${product.littleUnit}</td>
                            <td>${product.purchasePrice }/${product.littleUnit}</td>
                            <td>
                                <input type="text" name="" value="${product.mainpageSortNum}"/>
                            </td>
                            <td>
                                <button class="detail">详情</button>
                                <button class="delete" onclick="deleteMainpageProduct(${product.id},this)">删除</button>
                            </td>
                        </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                     <div id="table_id_wrapper" class="dataTables_wrapper form-inline no-footer clearfix" style="font-size:14px;">  
				    <div class="dataTables_length" style="float: left;">  
				        <label> 每页${page.pageSize}条一共${page.pages}页 共 ${page.total } 条记录 | 每页显示： <select id="pageSize" name="table_id_length" aria-controls="table_id" class="form-control input-sm">  
				                <option value="2" ${page.pageSize eq 2?'selected':'' }>2</option>  
				                <option value="5" ${page.pageSize eq 5?'selected':'' }>5</option>  
				                <option value="10" ${page.pageSize eq 10?'selected':'' }>10</option>  
				                <option value="20" ${page.pageSize eq 20?'selected':'' }>20</option>  
				                <!-- <option value="-1" ${page.pageSize eq -1?'selected':'' }>All</option>  -->  
				        </select>  
				        </label>  
				    </div>  
	  
					<c:if test="${page.pages gt 1}">  
				       <div class="dataTables_paginate paging_simple_numbers" id="table_id_paginate" style="float: right;">  
				            <ul class="pagination" style="margin-right:20px;">  
				                <li class="paginate_button previous ${page.pageNum eq 1?'disabled':'paginate_button_js' }" data-index="1"><a href="${pageContext.request.contextPath}/mainPage/mainPageIndex?pageNum=${page.firstPage}&pageSize=${page.pageSize}">最前</a></li>  
				                <li class="paginate_button previous ${page.pageNum eq 1?'disabled':'' }" aria-controls="table_id" tabindex="0" id="table_id_previous"><a href="${pageContext.request.contextPath}/mainPage/mainPageIndex?pageNum=${page.prePage}&pageSize=${page.pageSize}">上一页</a></li>  
				                <c:forEach items="${page.navigatepageNums }" var="index">  
				                    <li class="paginate_button ${page.pageNum eq index?'active':'paginate_button_js' }" aria-controls="table_id" data-index="${index}"><a href="${pageContext.request.contextPath}/mainPage/mainPageIndex?pageNum=${index}&pageSize=${page.pageSize}">${index }</a></li>  
				                </c:forEach>  
				                <li class="paginate_button next ${page.pageNum eq page.pages?'disabled':'' }" aria-controls="table_id" tabindex="0" id="table_id_next"><a href="${pageContext.request.contextPath}/mainPage/mainPageIndex?pageNum=${page.nextPage}&pageSize=${page.pageSize}" >下一页</a></li>  
				                <li class="paginate_button next ${page.pageNum eq page.pages?'disabled':'paginate_button_js' }" data-index="${page.pages }"><a href="${pageContext.request.contextPath}/mainPage/mainPageIndex?pageNum=${page.lastPage}&pageSize=${page.pageSize}">最后</a></li>  
				                <li class="display_inlineblock paginate_text" style="margin-left:10px;"> 跳转到第 <input id="page" type="text" class="form-control input-sm" size="2"> 页  
				                <button id="page-forward" type="button" class="btn btn-sm btn-default" style="letter-spacing:3px;">确定</button></li>  
				            </ul>  
				        </div>  
				    </c:if>  
				</div>  
<script type="text/javascript">  
	$(document).ready(function() {  
			 $('#table_id_paginate').on('click','a',function(e){
				 //e.preventDefault();
			 });
	  	$('#pageSize').change(function(){
	  		var count=$(this).val();
	  		window.location.href = "/DistributorSystem/mainPage/mainPageIndex?pageSize="+count;
	  	});    
	  	$('#page-forward').click(function(){
	  		var pageNum=$(this).siblings('input').val();	
	  		window.location.href = "/DistributorSystem/mainPage/mainPageIndex?pageNum="+pageNum+"&pageSize="+${page.pageSize};
	  	});
	})  
</script>  
                    
                    <div class="fix-btn">
                        <input type="submit" class="submit" value="保存"/>
                        <input type="reset" class="reset" value="取消"/>
                    </div>
                </div>
            </form>
            <form class="add-form hide" action="">
                <div class="content add-block" style="height: 700px">
                    <div class="search-box fl">
                        <input id="condition" type="text" placeholder="请输入商品名称/关键字/条形码"/>
                        <span onclick="getProduct()"></span>
                    </div>
                    <div class="add-more fr">批量添加</div>
                    <table>
                        <thead>
                        <tr>
                            <td><s></s></td>
                            <td>商品图片</td>
                            <td>商品名称</td>
                            <td>规格</td>
                            <td>标准</td>
                            <td>市场价</td>
                            <td>订货价</td>
                            <td>进货价</td>
                            <td>排序值</td>
                            <td></td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="products" items="${findAllProducts }" >
                        <tr>
                            <td><s></s></td>
                            <td>
                                <div>
                                    <img src="${pageContext.request.contextPath}/img/1.jpg"/>
                                </div>

                            </td>
                            <td>
                                <p>${products.code }</p>
                                <p>${products.productName }</p>
                                <p>${products.brandName }</p>
                            </td>
                            <td>${products.groupSpecValue }</td>
                            <td>${products.standard }</td>
                            <td>${products.price }/${products.littleUnit}</td>
                            <td>${products.orderedPrice }/${products.littleUnit}</td>
                            <td>${products.purchasePrice }/${products.littleUnit}</td>
                            <td>
                                <input type="text" id="addSortNum" value="${products.mainpageSortNum}"/>
                            </td>
                            <td>
                                <button class="detail">详情</button>
                                <button class="add" onclick="addActivityProduct(${products.id})">添加</button>
                            </td>
                        </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div class="fix-btn">
                        <input type="submit" class="submit" value="保存"/>
                        <input type="reset" class="reset" value="取消"/>
                    </div>
                </div>
            </form>
        </div>
        <script src="${pageContext.request.contextPath}/static/orderlang/distributor/js/mainpage_product.js"></script>
        <!--内容部分结束-->
    </div>
</div>
</body>
</html>